import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text(''),
        ),
        // 使用普通线性布局，当子元素超过父元素大小时，会报错，可以使用流式布局自动换行，或者使用可滚动组件
        body: Wrap(
          direction: Axis.horizontal,
          alignment: WrapAlignment.start,
          // 子控件在主轴方向间距
          spacing: 10.0,
          // 纵轴间距
          runSpacing: 10.0,
          runAlignment: WrapAlignment.start,
          children: [
            Container(
              child: null,
              width: 100.0,
              height: 50.0,
              color: Colors.redAccent,
            ),
            Container(
              child: null,
              width: 050.0,
              height: 50.0,
              color: Colors.yellow,
            ),
            Container(
              child: null,
              width: 250.0,
              height: 50.0,
              color: Colors.blue,
            ),
            Container(
              child: null,
              width: 30.0,
              height: 50.0,
              color: Colors.pink,
            )
          ],
        ),
      ),
    );
  }
}
